//
//  TF_TopRightOrCornerTopLeft.swift
//  TalkfunSDKDemo
//
//  Created by 莫瑞权 on 2022/3/27.
//  Copyright © 2022 Talkfun. All rights reserved.
//

import UIKit

class TF_TopRightOrCornerTopLeft: UIButton {
    
    var maskPath:UIBezierPath?
    var maskLayer:CAShapeLayer?

    override init(frame: CGRect) {
        super.init(frame: frame)

    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
      
        
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    @objc public func initMask()
    {
        let maskeight:CGFloat = 12
        if (self.maskPath == nil && self.bounds.size.width > 0) {
            
            self.maskPath = UIBezierPath.init(roundedRect: self.bounds, byRoundingCorners:[UIRectCorner.topRight,UIRectCorner.topLeft], cornerRadii: CGSize(width: maskeight, height: maskeight))
            
            self.maskLayer = CAShapeLayer.init()
      
        
        }
        
        self.maskLayer!.frame = self.bounds;
        self.maskLayer!.path = self.maskPath?.cgPath;
        self.layer.mask =  self.maskLayer;
        
    }
    
}
